import Koa from "koa";
import path from "path";
import cors from "@koa/cors";
import router from "./router";
import staticSource from "koa-static";
import fs from "fs";
import https from "https";
import bodyParser from "koa-bodyparser";
const app: Koa = new Koa();
app.use(cors());
app.use(bodyParser());
// app.use(staticSource(path.join(__dirname, 'static')));
router(app);
const options = {
  key: fs.readFileSync(
    path.resolve(__dirname, "../localhost.midea.com+2-key.pem")
  ),
  cert: fs.readFileSync(
    path.resolve(__dirname, "../localhost.midea.com+2.pem")
  ),
};
https.createServer(options, app.callback()).listen(3001, () => {
  console.log("server is running at https://localhost:3001");
});
